package com.woniuxy.provider;

import org.apache.ibatis.jdbc.SQL;
import org.junit.Test;
import org.mockito.internal.matchers.And;
import org.springframework.boot.test.context.SpringBootTest;

import com.woniuxy.pojo.FindRoom;
@SpringBootTest
public class FindRoomProvider {
	//查询符合要求的房子
	@Test
	public String findRooms(FindRoom findRoom){
		SQL sql=new SQL();
		sql.SELECT("*").FROM("room r","roomimg ro","roomtype rt").WHERE("r.rtid=rt.rtid and r.rid=ro.rid and r.rid IN")
		.SELECT_DISTINCT("rid").FROM("orderdetail").WHERE("!((#{checkin} BETWEEN checkin AND checkout AND (#{checkout} BETWEEN checkin AND checkout))))");
		if(findRoom.getRtid()!=0){
			sql.WHERE("rtid="+findRoom.getRtid());
		}
		if(findRoom.getRfoot()!=null&& findRoom.getRfoot()!=""){
			sql.WHERE("rfoot='"+findRoom.getRfoot()+"'");
		}
		if(findRoom.getRwindow()!=null&& findRoom.getRwindow()!=""){
			sql.WHERE("rwindow='"+findRoom.getRwindow()+"'");
		}
		if(findRoom.getRspring()!=null&& findRoom.getRspring()!=""){
			sql.WHERE("rspring='"+findRoom.getRspring()+"'");
		}
		return sql.toString();	
	}

}